package com.snowj.apaas.repository.auto;

import static com.snowj.apaas.repository.auto.AgreementsDynamicSqlSupport.*;
import static org.mybatis.dynamic.sql.SqlBuilder.*;

import com.snowj.apaas.domain.auto.Agreements;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import javax.annotation.Generated;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;
import org.mybatis.dynamic.sql.BasicColumn;
import org.mybatis.dynamic.sql.delete.DeleteDSLCompleter;
import org.mybatis.dynamic.sql.delete.render.DeleteStatementProvider;
import org.mybatis.dynamic.sql.insert.render.InsertStatementProvider;
import org.mybatis.dynamic.sql.insert.render.MultiRowInsertStatementProvider;
import org.mybatis.dynamic.sql.select.CountDSLCompleter;
import org.mybatis.dynamic.sql.select.SelectDSLCompleter;
import org.mybatis.dynamic.sql.select.render.SelectStatementProvider;
import org.mybatis.dynamic.sql.update.UpdateDSL;
import org.mybatis.dynamic.sql.update.UpdateDSLCompleter;
import org.mybatis.dynamic.sql.update.UpdateModel;
import org.mybatis.dynamic.sql.update.render.UpdateStatementProvider;
import org.mybatis.dynamic.sql.util.SqlProviderAdapter;
import org.mybatis.dynamic.sql.util.mybatis3.MyBatis3Utils;

@Mapper
public interface AgreementsMapper {
    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-26T19:41:51.863802+08:00", comments="Source Table: agreements")
    BasicColumn[] selectList = BasicColumn.columnList(id, clientId, signingDate, projectInfo, businessPeople, engineer, account, password, process, signMoney, remarks, createdBy, createdDate, lastModifiedBy, lastModifiedDate);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-26T19:41:51.824311+08:00", comments="Source Table: agreements")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    long count(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-26T19:41:51.828124+08:00", comments="Source Table: agreements")
    @DeleteProvider(type=SqlProviderAdapter.class, method="delete")
    int delete(DeleteStatementProvider deleteStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-26T19:41:51.828807+08:00", comments="Source Table: agreements")
    @InsertProvider(type=SqlProviderAdapter.class, method="insert")
    @Options(useGeneratedKeys=true,keyProperty="record.id")
    int insert(InsertStatementProvider<Agreements> insertStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-26T19:41:51.845933+08:00", comments="Source Table: agreements")
    @Insert({
        "${insertStatement}"
    })
    @Options(useGeneratedKeys=true,keyProperty="records.id")
    int insertMultiple(@Param("insertStatement") String insertStatement, @Param("records") List<Agreements> records);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-26T19:41:51.847779+08:00", comments="Source Table: agreements")
    default int insertMultiple(MultiRowInsertStatementProvider<Agreements> multipleInsertStatement) {
        return insertMultiple(multipleInsertStatement.getInsertStatement(), multipleInsertStatement.getRecords());
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-26T19:41:51.848577+08:00", comments="Source Table: agreements")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @ResultMap("AgreementsResult")
    Optional<Agreements> selectOne(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-26T19:41:51.849328+08:00", comments="Source Table: agreements")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @Results(id="AgreementsResult", value = {
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="client_id", property="clientId", jdbcType=JdbcType.BIGINT),
        @Result(column="signing_date", property="signingDate", jdbcType=JdbcType.DATE),
        @Result(column="project_info", property="projectInfo", jdbcType=JdbcType.VARCHAR),
        @Result(column="business_people", property="businessPeople", jdbcType=JdbcType.VARCHAR),
        @Result(column="engineer", property="engineer", jdbcType=JdbcType.VARCHAR),
        @Result(column="account", property="account", jdbcType=JdbcType.VARCHAR),
        @Result(column="password", property="password", jdbcType=JdbcType.VARCHAR),
        @Result(column="process", property="process", jdbcType=JdbcType.INTEGER),
        @Result(column="sign_money", property="signMoney", jdbcType=JdbcType.VARCHAR),
        @Result(column="remarks", property="remarks", jdbcType=JdbcType.VARCHAR),
        @Result(column="created_by", property="createdBy", jdbcType=JdbcType.VARCHAR),
        @Result(column="created_date", property="createdDate", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="last_modified_by", property="lastModifiedBy", jdbcType=JdbcType.VARCHAR),
        @Result(column="last_modified_date", property="lastModifiedDate", jdbcType=JdbcType.TIMESTAMP)
    })
    List<Agreements> selectMany(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-26T19:41:51.854165+08:00", comments="Source Table: agreements")
    @UpdateProvider(type=SqlProviderAdapter.class, method="update")
    int update(UpdateStatementProvider updateStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-26T19:41:51.854722+08:00", comments="Source Table: agreements")
    default long count(CountDSLCompleter completer) {
        return MyBatis3Utils.countFrom(this::count, agreements, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-26T19:41:51.855236+08:00", comments="Source Table: agreements")
    default int delete(DeleteDSLCompleter completer) {
        return MyBatis3Utils.deleteFrom(this::delete, agreements, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-26T19:41:51.855968+08:00", comments="Source Table: agreements")
    default int deleteByPrimaryKey(Long id_) {
        return delete(c -> 
            c.where(id, isEqualTo(id_))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-26T19:41:51.856613+08:00", comments="Source Table: agreements")
    default int insert(Agreements record) {
        return MyBatis3Utils.insert(this::insert, record, agreements, c ->
            c.map(clientId).toProperty("clientId")
            .map(signingDate).toProperty("signingDate")
            .map(projectInfo).toProperty("projectInfo")
            .map(businessPeople).toProperty("businessPeople")
            .map(engineer).toProperty("engineer")
            .map(account).toProperty("account")
            .map(password).toProperty("password")
            .map(process).toProperty("process")
            .map(signMoney).toProperty("signMoney")
            .map(remarks).toProperty("remarks")
            .map(createdBy).toProperty("createdBy")
            .map(createdDate).toProperty("createdDate")
            .map(lastModifiedBy).toProperty("lastModifiedBy")
            .map(lastModifiedDate).toProperty("lastModifiedDate")
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-26T19:41:51.86044+08:00", comments="Source Table: agreements")
    default int insertMultiple(Collection<Agreements> records) {
        return MyBatis3Utils.insertMultiple(this::insertMultiple, records, agreements, c ->
            c.map(clientId).toProperty("clientId")
            .map(signingDate).toProperty("signingDate")
            .map(projectInfo).toProperty("projectInfo")
            .map(businessPeople).toProperty("businessPeople")
            .map(engineer).toProperty("engineer")
            .map(account).toProperty("account")
            .map(password).toProperty("password")
            .map(process).toProperty("process")
            .map(signMoney).toProperty("signMoney")
            .map(remarks).toProperty("remarks")
            .map(createdBy).toProperty("createdBy")
            .map(createdDate).toProperty("createdDate")
            .map(lastModifiedBy).toProperty("lastModifiedBy")
            .map(lastModifiedDate).toProperty("lastModifiedDate")
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-26T19:41:51.861335+08:00", comments="Source Table: agreements")
    default int insertSelective(Agreements record) {
        return MyBatis3Utils.insert(this::insert, record, agreements, c ->
            c.map(clientId).toPropertyWhenPresent("clientId", record::getClientId)
            .map(signingDate).toPropertyWhenPresent("signingDate", record::getSigningDate)
            .map(projectInfo).toPropertyWhenPresent("projectInfo", record::getProjectInfo)
            .map(businessPeople).toPropertyWhenPresent("businessPeople", record::getBusinessPeople)
            .map(engineer).toPropertyWhenPresent("engineer", record::getEngineer)
            .map(account).toPropertyWhenPresent("account", record::getAccount)
            .map(password).toPropertyWhenPresent("password", record::getPassword)
            .map(process).toPropertyWhenPresent("process", record::getProcess)
            .map(signMoney).toPropertyWhenPresent("signMoney", record::getSignMoney)
            .map(remarks).toPropertyWhenPresent("remarks", record::getRemarks)
            .map(createdBy).toPropertyWhenPresent("createdBy", record::getCreatedBy)
            .map(createdDate).toPropertyWhenPresent("createdDate", record::getCreatedDate)
            .map(lastModifiedBy).toPropertyWhenPresent("lastModifiedBy", record::getLastModifiedBy)
            .map(lastModifiedDate).toPropertyWhenPresent("lastModifiedDate", record::getLastModifiedDate)
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-26T19:41:51.867592+08:00", comments="Source Table: agreements")
    default Optional<Agreements> selectOne(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectOne(this::selectOne, selectList, agreements, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-26T19:41:51.868172+08:00", comments="Source Table: agreements")
    default List<Agreements> select(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectList(this::selectMany, selectList, agreements, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-26T19:41:51.86874+08:00", comments="Source Table: agreements")
    default List<Agreements> selectDistinct(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectDistinct(this::selectMany, selectList, agreements, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-26T19:41:51.869406+08:00", comments="Source Table: agreements")
    default Optional<Agreements> selectByPrimaryKey(Long id_) {
        return selectOne(c ->
            c.where(id, isEqualTo(id_))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-26T19:41:51.872237+08:00", comments="Source Table: agreements")
    default int update(UpdateDSLCompleter completer) {
        return MyBatis3Utils.update(this::update, agreements, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-26T19:41:51.873142+08:00", comments="Source Table: agreements")
    static UpdateDSL<UpdateModel> updateAllColumns(Agreements record, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(clientId).equalTo(record::getClientId)
                .set(signingDate).equalTo(record::getSigningDate)
                .set(projectInfo).equalTo(record::getProjectInfo)
                .set(businessPeople).equalTo(record::getBusinessPeople)
                .set(engineer).equalTo(record::getEngineer)
                .set(account).equalTo(record::getAccount)
                .set(password).equalTo(record::getPassword)
                .set(process).equalTo(record::getProcess)
                .set(signMoney).equalTo(record::getSignMoney)
                .set(remarks).equalTo(record::getRemarks)
                .set(createdBy).equalTo(record::getCreatedBy)
                .set(createdDate).equalTo(record::getCreatedDate)
                .set(lastModifiedBy).equalTo(record::getLastModifiedBy)
                .set(lastModifiedDate).equalTo(record::getLastModifiedDate);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-26T19:41:51.87406+08:00", comments="Source Table: agreements")
    static UpdateDSL<UpdateModel> updateSelectiveColumns(Agreements record, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(clientId).equalToWhenPresent(record::getClientId)
                .set(signingDate).equalToWhenPresent(record::getSigningDate)
                .set(projectInfo).equalToWhenPresent(record::getProjectInfo)
                .set(businessPeople).equalToWhenPresent(record::getBusinessPeople)
                .set(engineer).equalToWhenPresent(record::getEngineer)
                .set(account).equalToWhenPresent(record::getAccount)
                .set(password).equalToWhenPresent(record::getPassword)
                .set(process).equalToWhenPresent(record::getProcess)
                .set(signMoney).equalToWhenPresent(record::getSignMoney)
                .set(remarks).equalToWhenPresent(record::getRemarks)
                .set(createdBy).equalToWhenPresent(record::getCreatedBy)
                .set(createdDate).equalToWhenPresent(record::getCreatedDate)
                .set(lastModifiedBy).equalToWhenPresent(record::getLastModifiedBy)
                .set(lastModifiedDate).equalToWhenPresent(record::getLastModifiedDate);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-26T19:41:51.875683+08:00", comments="Source Table: agreements")
    default int updateByPrimaryKey(Agreements record) {
        return update(c ->
            c.set(clientId).equalTo(record::getClientId)
            .set(signingDate).equalTo(record::getSigningDate)
            .set(projectInfo).equalTo(record::getProjectInfo)
            .set(businessPeople).equalTo(record::getBusinessPeople)
            .set(engineer).equalTo(record::getEngineer)
            .set(account).equalTo(record::getAccount)
            .set(password).equalTo(record::getPassword)
            .set(process).equalTo(record::getProcess)
            .set(signMoney).equalTo(record::getSignMoney)
            .set(remarks).equalTo(record::getRemarks)
            .set(createdBy).equalTo(record::getCreatedBy)
            .set(createdDate).equalTo(record::getCreatedDate)
            .set(lastModifiedBy).equalTo(record::getLastModifiedBy)
            .set(lastModifiedDate).equalTo(record::getLastModifiedDate)
            .where(id, isEqualTo(record::getId))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2023-03-26T19:41:51.876684+08:00", comments="Source Table: agreements")
    default int updateByPrimaryKeySelective(Agreements record) {
        return update(c ->
            c.set(clientId).equalToWhenPresent(record::getClientId)
            .set(signingDate).equalToWhenPresent(record::getSigningDate)
            .set(projectInfo).equalToWhenPresent(record::getProjectInfo)
            .set(businessPeople).equalToWhenPresent(record::getBusinessPeople)
            .set(engineer).equalToWhenPresent(record::getEngineer)
            .set(account).equalToWhenPresent(record::getAccount)
            .set(password).equalToWhenPresent(record::getPassword)
            .set(process).equalToWhenPresent(record::getProcess)
            .set(signMoney).equalToWhenPresent(record::getSignMoney)
            .set(remarks).equalToWhenPresent(record::getRemarks)
            .set(createdBy).equalToWhenPresent(record::getCreatedBy)
            .set(createdDate).equalToWhenPresent(record::getCreatedDate)
            .set(lastModifiedBy).equalToWhenPresent(record::getLastModifiedBy)
            .set(lastModifiedDate).equalToWhenPresent(record::getLastModifiedDate)
            .where(id, isEqualTo(record::getId))
        );
    }
}